package com.heima.wemedia;

import com.heima.aliyun.scan.GreenScan;
import com.heima.aliyun.scan.ScanResult;
import com.heima.utils.common.SensitiveWordUtil;
import com.heima.wemedia.service.WmNewsAutoScanService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@SpringBootTest
public class test01 {
    @Autowired
    GreenScan greenScan;
    @Test
    public void scanText(){
        try {
            ScanResult scanResult = greenScan.greenTextScan("冰毒不可取，k粉也不行");
            System.out.println(scanResult);
        } catch (Exception e) {
            e.printStackTrace();
            System.out.println("阿里云调用失败");
        }
    }

    @Test
    public void scanText2(){
        List<String> list = new ArrayList<>();
        list.add("病毒");
        list.add("冰毒");

        SensitiveWordUtil.initMap(list);

        String content="我是一个好人，买卖冰毒是违法的特朗普";

        Map<String, Integer> con = SensitiveWordUtil.matchWords(content);

        System.out.println(con);


    }
    @Autowired
    WmNewsAutoScanService wmNewsAutoScanService;
    @Test
    public void autoScan(){
        wmNewsAutoScanService.autoScanWmNews(6322);
    }
}
